<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css"
          href="jquery/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="jquery/bs_pagination-master/css/jquery.bs_pagination.min.css">

    <script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
    <script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="jquery/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript"
            src="jquery/bootstrap-datetimepicker-master/locale/bootstrap-datetimepicker.zh-CN.js"></script>
    <script type="text/javascript" src="jquery/bs_pagination-master/js/jquery.bs_pagination.min.js"></script>
    <script type="text/javascript" src="jquery/bs_pagination-master/localization/en.js"></script>

    <script type="text/javascript">

        //默认情况下取消和保存按钮是隐藏的
        var cancelAndSaveBtnDefault = true;

        $(function () {
            $(".mydate").datetimepicker({
                language: 'zh-CN', //语言
                format: 'yyyy-mm-dd',//日期的格式
                minView: 'month', //可以选择的最小视图
                initialDate: new Date(),//初始化显示的日期
                autoclose: true,//设置选择完日期或者时间之后，日否自动关闭日历
                todayBtn: true,//设置是否显示"今天"按钮,默认是false
                clearBtn: true//设置是否显示"清空"按钮，默认是false
            });

            $("#remark").focus(function () {
                if (cancelAndSaveBtnDefault) {
                    //设置remarkDiv的高度为130px
                    $("#remarkDiv").css("height", "130px");
                    //显示
                    $("#cancelAndSaveBtn").show("2000");
                    cancelAndSaveBtnDefault = false;
                }
            });

            $("#cancelBtn").click(function () {
                //显示
                $("#cancelAndSaveBtn").hide();
                //设置remarkDiv的高度为130px
                $("#remarkDiv").css("height", "90px");
                cancelAndSaveBtnDefault = true;
            });

            $("#remarkDivList").on("mouseover", ".remarkDiv", function () {
                $(this).children("div").children("div").show();
            });

            $("#remarkDivList").on("mouseout", ".remarkDiv", function () {
                $(this).children("div").children("div").hide();
            });

            $("#remarkDivList").on("mouseover", ".myHref", function () {
                $(this).children("span").css("color", "red");
            });

            $("#remarkDivList").on("mouseout", ".myHref", function () {
                $(this).children("span").css("color", "#E6E6E6");
            });

            //给"编辑"按钮添加单击事件
            $("#updateContactsBtn").click(function () {
                var id = '${contacts.id}';
                //发送请求
                $.ajax({
                    url: 'workbench/contacts/queryContactsById',
                    data: {
                        id: id
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        //把联系人的信息显示在修改的模态窗口上
                        $("#edit-id").val(data.id);
                        $("#edit-contactsOwner").val(data.owner);
                        $("#edit-clueSource1").val(data.source);
                        $("#edit-surname").val(data.fullname);
                        $("#edit-call").val(data.appellation);
                        $("#edit-job").val(data.job);
                        $("#edit-mphone").val(data.mphone);
                        $("#edit-email").val(data.email);
                        $("#edit-customerName").val(data.customerId);
                        $("#edit-describe").val(data.description);
                        $("#edit-contactSummary").val(data.contactSummary);
                        $("#edit-nextContactTime").val(data.nextContactTime);
                        $("#edit-address2").val(data.address);
                        //弹出模态窗口
                        $("#editContactsModal").modal("show");
                    }
                });
            });

            //给"更新"按钮添加单击事件
            $("#saveEditContactsBtn").click(function () {
                //收集参数
                var id = $("#edit-id").val();
                var owner = $("#edit-contactsOwner").val();
                var source = $.trim($("#edit-clueSource1").val());
                var fullname = $("#edit-surname").val();
                var appellation = $("#edit-call").val();
                var job = $.trim($("#edit-job").val());
                var mphone = $.trim($("#edit-mphone").val());
                var email = $.trim($("#edit-email").val());
                var customerId = $.trim($("#edit-customerName").val());
                var description = $.trim($("#edit-describe").val());
                var contactSummary = $.trim($("#edit-contactSummary").val());
                var nextContactTime = $.trim($("#edit-nextContactTime").val());
                var address = $.trim($("#edit-address2").val());

                //发送请求
                $.ajax({
                    url: 'workbench/contact/saveEditContacts',
                    data: {
                        id: id,
                        owner: owner,
                        source: source,
                        fullname: fullname,
                        appellation: appellation,
                        job: job,
                        mphone: mphone,
                        email: email,
                        customerId: customerId,
                        description: description,
                        contactSummary: contactSummary,
                        nextContactTime: nextContactTime,
                        address: address
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == "1") {
                            alert("修改成功~")
                            //跳转到联系人详情页面
                            window.location.href = "workbench/contacts/detail?id=${contacts.id}"

                        } else {
                            //提示信息
                            alert(data.message);
                            //模态窗口不关闭
                            $("#editContactsModal").modal("show");
                        }
                    }
                });
            });

            //给"删除"按钮添加单击事件
            $("#deleteContactsBtn").click(function () {
                if (window.confirm("确定删除吗？")) {
                    var id = '${contacts.id}';

                    //发送请求
                    $.ajax({
                        url: 'workbench/contacts/deleteContacts',
                        data: {
                            id: id
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (data) {
                            if (data.code == "1") {
                                alert("删除成功~")
                                //跳转到联系人详情页面
                                window.location.href = "workbench/contacts/index"
                            } else {
                                //提示信息
                                alert(data.message);
                            }
                        }
                    });
                }
            });

            //给"保存"按钮添加单击事件
            $("#saveCreateContactsRemarkBtn").click(function () {
                //收集参数
                var noteContent = $.trim($("#remark").val());
                var contactsId = '${contacts.id}';
                //表单验证
                if (noteContent == "") {
                    alert("备注内容不能为空");
                    return;
                }
                //发送请求
                $.ajax({
                    url: 'workbench/contacts/remark/add',
                    data: {
                        noteContent: noteContent,
                        contactsId: contactsId
                    },
                    type: 'post',
                    dateType: 'json',
                    success: function (data) {
                        if (data.code == "1") {
                            //清空输入框
                            $("#remark").val("");
                            //刷新备注列表
                            var htmlStr = "";
                            htmlStr += "<div id=\"div_" + data.retData.id + "\" class=\"remarkDiv\" style=\"height: 60px;\">";
                            htmlStr += "<img title=\"${sessionScope.sessionUser.name}\" src=\"image/user-thumbnail.png\" style=\"width: 30px; height:30px;\">";
                            htmlStr += "<div style=\"position: relative; top: -40px; left: 40px;\" >";
                            htmlStr += "<h5>${contacts.fullname}(${clue.appellation})</h5>";
                            htmlStr += "<font color=\"gray\">联系人</font> <font color=\"gray\">-</font> <b>" + data.retData.noteContent + "</b> <small style=\"color: gray;\"> " + data.retData.createTime + " 由${sessionScope.sessionUser.name}创建</small>";
                            htmlStr += "<div style=\"position: relative; left: 500px; top: -30px; height: 30px; width: 100px; display: none;\">";
                            htmlStr += "<a class=\"myHref\" name=\"editA\" remarkId=\"" + data.retData.id + "\" href=\"javascript:void(0);\"><span class=\"glyphicon glyphicon-edit\" style=\"font-size: 20px; color: #E6E6E6;\"></span></a>";
                            htmlStr += "&nbsp;&nbsp;&nbsp;&nbsp;";
                            htmlStr += "<a class=\"myHref\" name=\"deleteA\" remarkId=\"" + data.retData.id + "\" href=\"javascript:void(0);\"><span class=\"glyphicon glyphicon-remove\" style=\"font-size: 20px; color: #E6E6E6;\"></span></a>";
                            htmlStr += "</div>";
                            htmlStr += "</div>";
                            htmlStr += "</div>";
                            $("#remarkDiv").before(htmlStr);
                        } else {
                            //提示信息
                            alert(data.message);
                        }
                    }
                });
            });


            //给所有联系人备注后边的"删除"图标添加单击事件
            $("#remarkDivList").on("click", "a[name='deleteA']", function () {
                //收集参数
                var id = $(this).attr("remarkId");
                //发送请求
                $.ajax({
                    url: 'workbench/contacts/remark/delete',
                    data: {
                        id: id
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == "1") {
                            //刷新备注列表
                            $("#div_" + id).remove();
                        } else {
                            //提示信息
                            alert(data.message);
                        }
                    }
                });
            });

            //给所有联系人备注后边的"修改"图标添加单击事件
            $("#remarkDivList").on("click", "a[name='editA']", function () {
                //获取备注的id和noteContent
                var id = $(this).attr("remarkId");
                var noteCotent = $("#div_" + id + " b").text();
                //把备注的id和noteContent写到修改备注的模态窗口中
                $("#edit-remark-id").val(id);
                $("#edit-noteContent").val(noteCotent);
                //弹出修改市场活动备注的模态窗口
                $("#editRemarkModal").modal("show");
            });

            //给"备注 更新"按钮添加单击事件
            $("#updateRemarkBtn").click(function () {
                //收集参数
                var id = $("#edit-remark-id").val();
                var noteContent = $.trim($("#edit-noteContent").val());
                //表单验证
                if (noteContent == "") {
                    alert("备注内容不能为空");
                    return;
                }
                //发送请求
                $.ajax({
                    url: 'workbench/contacts/remark/update',
                    data: {
                        id: id,
                        noteContent: noteContent
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == "1") {
                            //关闭模态窗口
                            $("#editRemarkModal").modal("hide");
                            //刷新备注列表
                            $("#div_" + data.retData.id + " b").text(data.retData.noteContent);
                            $("#div_" + data.retData.id + " small").text(" " + data.retData.editTime + " 由${sessionScope.sessionUser.name}修改");
                        } else {
                            //提示信息
                            alert(data.message);
                            //模态窗口不关闭
                            $("#editRemarkModal").modal("show");
                        }
                    }
                });
            });

            //给"关联市场活动"按钮添加单击事件
            $("#bundActivityBtn").click(function () {
                //初始化工作
                //清空搜索框
                $("#searchActivityTxt").val("");
                //清空搜索的市场活动列表
                $("#tBody").html("");

                //弹出"线索关联市场活动"的模态窗口
                $("#bundModal").modal("show");
            });

            //给市场活动搜索框添加键盘弹起事件
            $("#searchActivityTxt").keyup(function () {
                //收集参数
                var activityName = this.value;
                var contactsId = '${contacts.id}';
                //发送请求
                $.ajax({
                    url: 'workbench/activity/queryActivityByNameAndContactsId',
                    data: {
                        activityName: activityName,
                        contactsId: contactsId
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        //遍历data，显示搜索到的市场活动列表
                        var htmlStr = "";
                        $.each(data, function (index, obj) {
                            htmlStr += "<tr>";
                            htmlStr += "<td><input type=\"checkbox\" value=\"" + obj.id + "\"/></td>";
                            htmlStr += "<td>" + obj.name + "</td>";
                            htmlStr += "<td>" + obj.startDate + "</td>";
                            htmlStr += "<td>" + obj.endDate + "</td>";
                            htmlStr += "<td>" + obj.owner + "</td>";
                            htmlStr += "</tr>";
                        });
                        $("#contactsActivityRelationTBody").html(htmlStr);
                    }
                });
            });

            //给"关联"按钮添加单击事件
            $("#saveBundActivityBtn").click(function () {
                //收集参数
                //获取列表中所有被选中的checkbox
                var chckedIds = $("#contactsActivityRelationTBody input[type='checkbox']:checked");
                //表单验证
                if (chckedIds.size() == 0) {
                    alert("请选择要关联的市场活动");
                    return;
                }
                var ids = "";
                $.each(chckedIds, function () {
                    ids += "activityId=" + this.value + "&";
                });
                ids += "contactsId=${contacts.id}";

                //发送请求
                $.ajax({
                    url: 'workbench/contacts/relation/bundActivity',
                    data: ids,
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == "1") {
                            //关闭模态窗口
                            $("#bundModal").modal("hide");
                            //刷新已经关联过的市场活动列表
                            var htmlStr = "";
                            $.each(data.retData, function (index, obj) {
                                htmlStr += "<tr id=\"tr_" + obj.id + "\">";
                                htmlStr += "<td>" + obj.name + "</td>";
                                htmlStr += "<td>" + obj.startDate + "</td>";
                                htmlStr += "<td>" + obj.endDate + "</td>";
                                htmlStr += "<td>" + obj.owner + "</td>";
                                htmlStr += "<td><a href=\"javascript:void(0);\" activityId=\"" + obj.id + "\"  style=\"text-decoration: none;\"><span class=\"glyphicon glyphicon-remove\"></span>解除关联</a></td>";
                                htmlStr += "</tr>";
                            });
                            $("#relationedTBody").append(htmlStr);
                        } else {
                            //提示信息
                            alert(data.message);
                            //模态窗口不关闭
                            $("#bundModal").modal("show");
                        }
                    }
                });
            });

            //给所有的"解除关联"按钮添加单击事件
            $("#relationedTBody").on("click", "a", function () {
                //收集参数
                var activityId = $(this).attr("activityId");
                var contactsId = "${contacts.id}";

                if (window.confirm("确定解除关联吗？")) {
                    //发送请求
                    $.ajax({
                        url: 'workbench/contacts/relation/unbundActivity',
                        data: {
                            activityId: activityId,
                            contactsId: contactsId
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (data) {
                            if (data.code == "1") {
                                //刷新已经关联的市场活动列表
                                $("#tr_" + activityId).remove();
                            } else {
                                //提示信息
                                alert(data.message);
                            }
                        }
                    });
                }
            });

            // 新建交易 单击事件
            $("#createTranBtn").click(function () {
                //重置表单
                $("#createTransactionForm")[0].reset();

                //弹出创建交易的模态窗口
                $("#createTransactionModal").modal("show");
            });

            //给"创建-保存"按钮添加单击事件
            $("#addTranBtn").click(function () {
                //收集参数
                var owner = $("#create-owner").val();
                var money = $.trim($("#create-money").val());
                var name = $.trim($("#create-name").val());
                var expectedDate = $("#create-expectedDate").val();
                var customerName = $.trim($("#create-customerName").val());
                var stage = $("#create-stage").val();
                var type = $("#create-type").val();
                var source = $("#create-source").val();
                var activityId = $("#create-activityId").val();
                var contactsId = '${contacts.id}';
                var description = $.trim($("#create-description").val());
                var contactSummary = $.trim($("#create-contactSummary").val());
                var nextContactTime = $("#create-nextContactTime").val();

                //表单校验
                if (owner == "") {
                    alert("所有者不能为空");
                    return;
                }
                if (name == "") {
                    alert("姓名不能为空");
                    return;
                }
                if (expectedDate == "") {
                    alert("预计成交日期不能为空");
                    return;
                }
                if (customerName == "") {
                    alert("客户名称不能为空");
                    return;
                }
                if (stage == "") {
                    alert("阶段不能为空");
                    return;
                }
                if (type == "") {
                    alert("类型不能为空");
                    return;
                }
                if (source == "") {
                    alert("来源不能为空");
                    return;
                }
                if (activityId == "") {
                    alert("市场活动不能为空");
                    return;
                }

                var regExp = /^(([1-9]\d*)|0)$/;
                if (!regExp.test(money)) {
                    alert("金额只能为非负整数");
                    return;
                }
                //发送请求
                $.ajax({
                    url: 'workbench/transaction/add',
                    data: {
                        owner: owner,
                        money: money,
                        name: name,
                        expectedDate: expectedDate,
                        customerName: customerName,
                        stage: stage,
                        type: type,
                        source: source,
                        activityId: activityId,
                        contactsId: contactsId,
                        description: description,
                        contactSummary: contactSummary,
                        nextContactTime: nextContactTime
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == "1") {
                            $("#createTransactionModal").modal("hide");
                            window.location.href = "workbench/contacts/detail?id=${contacts.id}"
                        } else {
                            //提示信息
                            alert(data.message);
                            $("#createTransactionModal").modal("show");//可以不写。
                        }
                    }
                });
            });

            //给"创建-市场活动源"搜索按钮添加单击事件
            $("#searchActivityBtn").click(function () {
                $("#searchActivityTxt2").val("");
                //清空搜索列表
                $("#activityTBody").html("");

                //弹出搜索市场活动的模态窗口
                $("#searchActivityModal").modal("show");
            });

            //给"创建-市场活动源"搜索框添加键盘弹起事件
            $("#searchActivityTxt2").keyup(function () {
                //收集参数
                var activityName = this.value;
                //发送请求
                $.ajax({
                    url: 'workbench/activity/queryActivityLikeName',
                    data: {
                        activityName: activityName
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        //遍历data,显示所有搜索的市场活动
                        var htmlStr = "";
                        $.each(data, function (index, obj) {
                            htmlStr += "<tr>";
                            htmlStr += "<td><input type=\"radio\" value=\"" + obj.id + "\" activityName=\"" + obj.name + "\" name=\"activity\"/></td>";
                            htmlStr += "<td>" + obj.name + "</td>";
                            htmlStr += "<td>" + obj.startDate + "</td>";
                            htmlStr += "<td>" + obj.endDate + "</td>";
                            htmlStr += "<td>" + obj.owner + "</td>";
                            htmlStr += "</tr>";
                        });
                        $("#activityTBody").html(htmlStr);
                    }
                });
            });

            //给"创建-市场活动源"的单选按钮添加单击事件
            $("#activityTBody").on("click", "input[type='radio']", function () {
                //获取市场活动的id和name
                var id = this.value;
                var activityName = $(this).attr("activityName");
                //把市场活动的id写到隐藏域，把name写到输入框中
                $("#create-activityId").val(id);
                $("#create-activityName").val(activityName);
                //关闭搜索市场活动的模态窗口
                $("#searchActivityModal").modal("hide");
            });


            //给所有的"新建交易-删除按钮"按钮添加单击事件
            $("#addTransactionTBody").on("click", "a", function () {
                //收集参数
                var transactionId = $(this).attr("transactionId");

                if (window.confirm("确定删除吗？")) {
                    //发送请求
                    $.ajax({
                        url: 'workbench/transtaction/deleteById',
                        data: {
                            transactionId: transactionId
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (data) {
                            if (data.code == "1") {
                                //刷新已经关联的市场活动列表
                                $("#tr_" + transactionId).remove();
                            } else {
                                //提示信息
                                alert(data.message);
                            }
                        }
                    });
                }
            });

        });

    </script>

</head>
<body>
<!-- 修改联系人备注的模态窗口 -->
<div class="modal fade" id="editRemarkModal" role="dialog">
    <%-- 备注的id --%>
    <input type="hidden" id="remarkId">
    <div class="modal-dialog" role="document" style="width: 40%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">修改备注</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <input type="hidden" id="edit-remark-id">
                    <div class="form-group">
                        <label for="edit-noteContent" class="col-sm-2 control-label">内容</label>
                        <div class="col-sm-10" style="width: 81%;">
                            <textarea class="form-control" rows="3" id="edit-noteContent"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="updateRemarkBtn">更新</button>
            </div>
        </div>
    </div>
</div>

<!-- 新建交易的模态窗口 -->
<div class="modal fade" id="createTransactionModal" role="dialog">
    <div class="modal-dialog" role="document" style="width: 85%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="myModalLabelx">新建交易</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="createTransactionForm" role="form">
                    <div class="form-group">
                        <label for="create-owner" class="col-sm-2 control-label">所有者<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="create-owner">
                                <c:forEach items="${userList}" var="u">
                                    <option value="${u.id}">${u.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <label for="create-money" class="col-sm-2 control-label">金额</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="create-money">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-name" class="col-sm-2 control-label">名称<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="create-name">
                        </div>
                        <label for="create-expectedDate" class="col-sm-2 control-label">预计成交日期<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control mydate" name="mydate" readonly
                                   id="create-expectedDate">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-customerName" class="col-sm-2 control-label">客户名称<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="create-customerName"
                                   placeholder="支持自动补全，输入客户不存在则新建">
                        </div>
                        <label for="create-stage" class="col-sm-2 control-label">阶段<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="create-stage">
                                <option></option>
                                <c:forEach items="${stageList}" var="s">
                                    <option value="${s.id}">${s.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-type" class="col-sm-2 control-label">类型</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="create-type">
                                <option></option>
                                <c:forEach items="${transactionTypeList}" var="tt">
                                    <option value="${tt.id}">${tt.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <label for="create-possibility" class="col-sm-2 control-label">可能性</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="create-possibility" readonly>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-source" class="col-sm-2 control-label">来源</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="create-source">
                                <option></option>
                                <c:forEach items="${sourceList}" var="so">
                                    <option value="${so.id}">${so.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <label for="create-activityName" class="col-sm-2 control-label">市场活动源&nbsp;&nbsp;<a
                                href="javascript:void(0);"
                                id="searchActivityBtn"
                                data-toggle="modal">
                            <span class="glyphicon glyphicon-search"></span></a></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="hidden" id="create-activityId">
                            <input type="text" class="form-control" id="create-activityName" readonly>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-description" class="col-sm-2 control-label">描述</label>
                        <div class="col-sm-10" style="width: 70%;">
                            <textarea class="form-control" rows="3" id="create-description"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-contactSummary" class="col-sm-2 control-label">联系纪要</label>
                        <div class="col-sm-10" style="width: 70%;">
                            <textarea class="form-control" rows="3" id="create-contactSummary"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="create-nextContactTime" class="col-sm-2 control-label">下次联系时间</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control mydate" name="mydate" readonly
                                   id="create-nextContactTime">
                        </div>
                    </div>
                </form>
            </div>
            <div style="position: relative; top: -40px; left: 70%;">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="addTranBtn">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- 查找市场活动模态窗口 -->
<div class="modal fade" id="searchActivityModal" role="dialog">
    <div class="modal-dialog" role="document" style="width: 80%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">查找市场活动</h4>
            </div>
            <div class="modal-body">
                <div class="btn-group" style="position: relative; top: 18%; left: 8px;">
                    <form class="form-inline" role="form">
                        <div class="form-group has-feedback">
                            <input id="searchActivityTxt2" type="text" class="form-control" style="width: 300px;"
                                   placeholder="请输入市场活动名称，支持模糊查询">
                            <span class="glyphicon glyphicon-search form-control-feedback"></span>
                        </div>
                    </form>
                </div>
                <table id="activityTable4" class="table table-hover"
                       style="width: 900px; position: relative;top: 10px;">
                    <thead>
                    <tr style="color: #B3B3B3;">
                        <td></td>
                        <td>名称</td>
                        <td>开始日期</td>
                        <td>结束日期</td>
                        <td>所有者</td>
                    </tr>
                    </thead>
                    <tbody id="activityTBody">
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<!-- 编辑联系人的模态窗口 -->
<div class="modal fade" id="editContactsModal" role="dialog">
    <div class="modal-dialog" role="document" style="width: 85%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="myModalLabel1">修改联系人</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">

                    <div class="form-group">
                        <input type="hidden" id="edit-id">
                        <label for="edit-contactsOwner" class="col-sm-2 control-label">所有者<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="edit-contactsOwner">
                                <c:forEach items="${userList}" var="u">
                                    <option value="${u.id}">${u.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <label for="edit-clueSource1" class="col-sm-2 control-label">联系人来源</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="edit-clueSource1">
                                <c:forEach items="${sourceList}" var="sl">
                                    <option value="${sl.id}">${sl.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="edit-surname" class="col-sm-2 control-label">姓名<span
                                style="font-size: 15px; color: red;">*</span></label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="edit-surname" value="李四">
                        </div>
                        <label for="edit-call" class="col-sm-2 control-label">称呼</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <select class="form-control" id="edit-call">
                                <c:forEach items="${appellationList}" var="app">
                                    <option value="${app.id}">${app.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="edit-job" class="col-sm-2 control-label">职位</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="edit-job" value="CTO">
                        </div>
                        <label for="edit-mphone" class="col-sm-2 control-label">手机</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="edit-mphone" value="12345678901">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="edit-email" class="col-sm-2 control-label">邮箱</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="edit-email" value="lisi@bjpowernode.com">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="edit-customerName" class="col-sm-2 control-label">客户名称</label>
                        <div class="col-sm-10" style="width: 300px;">
                            <input type="text" class="form-control" id="edit-customerName"
                                   placeholder="支持自动补全，输入客户不存在则新建" value="动力节点">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="edit-describe" class="col-sm-2 control-label">描述</label>
                        <div class="col-sm-10" style="width: 81%;">
                            <textarea class="form-control" rows="3" id="edit-describe">这是一条线索的描述信息</textarea>
                        </div>
                    </div>

                    <div style="height: 1px; width: 103%; background-color: #D5D5D5; left: -13px; position: relative;"></div>

                    <div style="position: relative;top: 15px;">
                        <div class="form-group">
                            <label for="edit-contactSummary" class="col-sm-2 control-label">联系纪要</label>
                            <div class="col-sm-10" style="width: 81%;">
                                <textarea class="form-control" rows="3" id="edit-contactSummary"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="edit-nextContactTime" class="col-sm-2 control-label">下次联系时间</label>
                            <div class="col-sm-10" style="width: 300px;">
                                <input type="text" class="form-control" id="edit-nextContactTime">
                            </div>
                        </div>
                    </div>

                    <div style="height: 1px; width: 103%; background-color: #D5D5D5; left: -13px; position: relative; top : 10px;"></div>

                    <div style="position: relative;top: 20px;">
                        <div class="form-group">
                            <label for="edit-address2" class="col-sm-2 control-label">详细地址</label>
                            <div class="col-sm-10" style="width: 81%;">
                                <textarea class="form-control" rows="1" id="edit-address2"></textarea>
                            </div>
                        </div>
                    </div>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal" id="saveEditContactsBtn">更新</button>
            </div>
        </div>
    </div>
</div>

<!-- 联系人关联市场活动的模态窗口 -->
<div class="modal fade" id="bundModal" role="dialog">
    <div class="modal-dialog" role="document" style="width: 80%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">关联市场活动</h4>
            </div>
            <div class="modal-body">
                <div class="btn-group" style="position: relative; top: 18%; left: 8px;">
                    <form class="form-inline" role="form">
                        <div class="form-group has-feedback">
                            <input type="text" id="searchActivityTxt" class="form-control" style="width: 300px;"
                                   placeholder="请输入市场活动名称，支持模糊查询">
                            <span class="glyphicon glyphicon-search form-control-feedback"></span>
                        </div>
                    </form>
                </div>
                <table id="activityTable" class="table table-hover" style="width: 900px; position: relative;top: 10px;">
                    <thead>
                    <tr style="color: #B3B3B3;">
                        <td><input type="checkbox"/></td>
                        <td>名称</td>
                        <td>开始日期</td>
                        <td>结束日期</td>
                        <td>所有者</td>
                        <td></td>
                    </tr>
                    </thead>
                    <tbody id="contactsActivityRelationTBody">

                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="saveBundActivityBtn">关联</button>
            </div>
        </div>
    </div>
</div>

<!-- 返回按钮 -->
<div style="position: relative; top: 35px; left: 10px;">
    <a href="javascript:void(0);" onclick="window.history.back();"><span class="glyphicon glyphicon-arrow-left"
                                                                         style="font-size: 20px; color: #DDDDDD"></span></a>
</div>

<!-- 大标题 -->
<div style="position: relative; left: 40px; top: -30px;">
    <div class="page-header">
        <h3>${contacts.fullname}(${contacts.appellation})
            <small> - ${contacts.customerId}</small>
        </h3>
    </div>
    <div style="position: relative; height: 50px; width: 500px;  top: -72px; left: 700px;">
        <button type="button" class="btn btn-default" data-toggle="modal" id="updateContactsBtn"><span
                class="glyphicon glyphicon-edit"></span> 编辑
        </button>
        <button type="button" class="btn btn-danger" id="deleteContactsBtn"><span
                class="glyphicon glyphicon-minus"></span> 删除
        </button>
    </div>
</div>

<br/>
<br/>
<br/>

<!-- 详细信息 -->
<div style="position: relative; top: -70px;">
    <div style="position: relative; left: 40px; height: 30px;">
        <div style="width: 300px; color: gray;">所有者</div>
        <div style="width: 300px;position: relative; left: 200px; top: -20px;"><b>${contacts.owner}</b></div>
        <div style="width: 300px;position: relative; left: 450px; top: -40px; color: gray;">来源</div>
        <div style="width: 300px;position: relative; left: 650px; top: -60px;"><b>${contacts.source}</b></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px;"></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px; left: 450px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 10px;">
        <div style="width: 300px; color: gray;">客户名称</div>
        <div style="width: 300px;position: relative; left: 200px; top: -20px;"><b>${contacts.customerId}</b></div>
        <div style="width: 300px;position: relative; left: 450px; top: -40px; color: gray;">姓名</div>
        <div style="width: 300px;position: relative; left: 650px; top: -60px;">
            <b>${contacts.fullname}${contacts.appellation}</b></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px;"></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px; left: 450px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 20px;">
        <div style="width: 300px; color: gray;">邮箱</div>
        <div style="width: 300px;position: relative; left: 200px; top: -20px;"><b>${contacts.email}</b></div>
        <div style="width: 300px;position: relative; left: 450px; top: -40px; color: gray;">手机</div>
        <div style="width: 300px;position: relative; left: 650px; top: -60px;"><b>${contacts.mphone}</b></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px;"></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px; left: 450px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 30px;">
        <div style="width: 300px; color: gray;">职位</div>
        <div style="width: 300px;position: relative; left: 200px; top: -20px;"><b>CTO</b></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px;"></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -60px; left: 450px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 40px;">
        <div style="width: 300px; color: gray;">创建者</div>
        <div style="width: 500px;position: relative; left: 200px; top: -20px;"><b>${contacts.createBy}&nbsp;&nbsp;</b>
            <small style="font-size: 10px; color: gray;">${contacts.createTime}</small>
        </div>
        <div style="height: 1px; width: 550px; background: #D5D5D5; position: relative; top: -20px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 50px;">
        <div style="width: 300px; color: gray;">修改者</div>
        <div style="width: 500px;position: relative; left: 200px; top: -20px;"><b>${contacts.editBy}&nbsp;&nbsp;</b>
            <small style="font-size: 10px; color: gray;">${contacts.editTime}</small>
        </div>
        <div style="height: 1px; width: 550px; background: #D5D5D5; position: relative; top: -20px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 60px;">
        <div style="width: 300px; color: gray;">描述</div>
        <div style="width: 630px;position: relative; left: 200px; top: -20px;">
            <b>
                ${contacts.description}
            </b>
        </div>
        <div style="height: 1px; width: 850px; background: #D5D5D5; position: relative; top: -20px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 70px;">
        <div style="width: 300px; color: gray;">联系纪要</div>
        <div style="width: 630px;position: relative; left: 200px; top: -20px;">
            <b>
                ${contacts.contactSummary}
            </b>
        </div>
        <div style="height: 1px; width: 850px; background: #D5D5D5; position: relative; top: -20px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 80px;">
        <div style="width: 300px; color: gray;">下次联系时间</div>
        <div style="width: 300px;position: relative; left: 200px; top: -20px;"><b>${contacts.nextContactTime}</b></div>
        <div style="height: 1px; width: 400px; background: #D5D5D5; position: relative; top: -20px;"></div>
    </div>
    <div style="position: relative; left: 40px; height: 30px; top: 90px;">
        <div style="width: 300px; color: gray;">详细地址</div>
        <div style="width: 630px;position: relative; left: 200px; top: -20px;">
            <b>
                ${contacts.address}
            </b>
        </div>
        <div style="height: 1px; width: 850px; background: #D5D5D5; position: relative; top: -20px;"></div>
    </div>
</div>
<!-- 备注 -->
<div style="position: relative; top: 20px; left: 40px;" id="remarkDivList">
    <div class="page-header">
        <h4>备注</h4>
    </div>

    <c:forEach items="${remarkList}" var="remark">
        <div class="remarkDiv" id="div_${remark.id}" style="height: 60px;">
            <img title="${remark.createBy}" src="image/user-thumbnail.png" style="width: 30px; height:30px;">
            <div style="position: relative; top: -40px; left: 40px;">
                <h5>${contacts.fullname}(${contacts.appellation})</h5>
                <font color="gray">联系人</font> <font color="gray">-</font>
                <b>${remark.noteContent}</b>
                <small style="color: gray;"> ${remark.editFlag=='0'?remark.createTime:remark.editTime}
                    由${remark.editFlag=='0'?remark.createBy:remark.editBy}${remark.editFlag=='0'?'创建':'修改'}</small>
                <div style="position: relative; left: 500px; top: -30px; height: 30px; width: 100px; display: none;">
                    <a class="myHref" name="editA" remarkId="${remark.id}" href="javascript:void(0);"><span
                            class="glyphicon glyphicon-edit" style="font-size: 20px; color: #E6E6E6;"></span></a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a class="myHref" name="deleteA" remarkId="${remark.id}" href="javascript:void(0);"><span
                            class="glyphicon glyphicon-remove" style="font-size: 20px; color: #E6E6E6;"></span></a>
                </div>
            </div>
        </div>
    </c:forEach>

    <div id="remarkDiv" style="background-color: #E6E6E6; width: 870px; height: 90px;">
        <form role="form" style="position: relative;top: 10px; left: 10px;">
            <textarea id="remark" class="form-control" style="width: 850px; resize : none;" rows="2"
                      placeholder="添加备注..."></textarea>
            <p id="cancelAndSaveBtn" style="position: relative;left: 737px; top: 10px; display: none;">
                <button id="cancelBtn" type="button" class="btn btn-default">取消</button>
                <button type="button" class="btn btn-primary" id="saveCreateContactsRemarkBtn">保存</button>
            </p>
        </form>
    </div>
</div>

<!-- 交易 -->
<div>
    <div style="position: relative; top: 20px; left: 40px;">
        <div class="page-header">
            <h4>交易</h4>
        </div>
        <div style="position: relative;top: 0px;">
            <table id="activityTable3" class="table table-hover" style="width: 900px;">
                <thead>
                <tr style="color: #B3B3B3;">
                    <td>名称</td>
                    <td>金额</td>
                    <td>阶段</td>
                    <td>预计成交日期</td>
                    <td>类型</td>
                    <td></td>
                </tr>
                </thead>
                <tbody id="addTransactionTBody">
                <c:forEach items="${transactionList}" var="tran">
                    <tr id="tr_${tran.id}">
                        <td>${tran.name}</td>
                        <td>${tran.money}</td>
                        <td>${tran.stage}</td>
                        <td>${tran.expectedDate}</td>
                        <td>${tran.type}</td>
                        <td><a href="javascript:void(0);" id="deleteTransactionBtn" transactionId="${tran.id}"
                               style="text-decoration: none;"><span
                                class="glyphicon glyphicon-remove"></span>删除</a></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
        <div>
            <a href="javascript:void(0);" id="createTranBtn" style="text-decoration: none;"><span
                    class="glyphicon glyphicon-plus"></span>新建交易</a>
        </div>
    </div>
</div>

<!-- 市场活动 -->
<div>
    <div style="position: relative; top: 60px; left: 40px;">
        <div class="page-header">
            <h4>市场活动</h4>
        </div>
        <div style="position: relative;top: 0px;">
            <table class="table table-hover" style="width: 900px;">
                <thead>
                <tr style="color: #B3B3B3;">
                    <td>名称</td>
                    <td>开始日期</td>
                    <td>结束日期</td>
                    <td>所有者</td>
                    <td></td>
                </tr>
                </thead>
                <tbody id="relationedTBody">
                <c:forEach items="${activityList}" var="act">
                    <tr id="tr_${act.id}">
                        <td>${act.name}</td>
                        <td>${act.startDate}</td>
                        <td>${act.endDate}</td>
                        <td>${act.owner}</td>
                        <td><a href="javascript:void(0);" activityId="${act.id}" style="text-decoration: none;"><span
                                class="glyphicon glyphicon-remove"></span>解除关联</a></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>

        <div>
            <a href="javascript:void(0);" id="bundActivityBtn" style="text-decoration: none;"><span
                    class="glyphicon glyphicon-plus"></span>关联市场活动</a>
        </div>
    </div>
</div>

<div style="height: 200px;"></div>
</body>
</html>